---
---

<head>
<title>{{ site.title }}</title>
<meta name="description" content="{{ site.description }}"/>
{% include langhead.html %}
</head>

{% assign pages=site.pages | where:"ref", 'home' | sort: 'lang' %}

<body>
<script>
var supported = [
{% assign supportedLangs = pages | map: 'lang' %}
{% for lang in supportedLangs %}
  {% if lang == supportedLangs.last %}
    '{{ lang }}'
  {% else %}
    '{{ lang }}',
  {% endif %}
{% endfor %}
];
var languages = getLangs();
redirect();

function redirect() {
  for (lang in languages) {
    for (supp in supported) {
      if (languages[lang].substring(0,2) == supported[supp].substring(0,2)) {
        window.location.replace("/" + supported[supp]);
        return;
      }
    }
  }
  window.location.replace("/en");
}

function getLangs(){
  return navigator.languages;
}

</script>

<p>If you are not automatically redirected, choose a language:</p>
<ul>
  {% for p in pages %}
  {% assign p_translation = site.data.translations[p.lang] %}

  {% if p.lang == "en" %}
  {% assign lang = p_translation.lang_name %}
  {% else %}
  {% assign lang = p_translation.lang_name | append: " — " | append: p_translation.lang_name_eng %}
  {% endif %}

  <li>
    <a href="{{ p.url }}">{{ lang }} </a>
  </li>
  {% endfor %}
</ul>
</body>
